#ifndef WIDGETHELPER_H
#define WIDGETHELPER_H

#include <QLabel>
#include <QMap>

class WidgetHelper
{
public:
    static bool equalizeWidgetWidth (const QList<QWidget*>& widgets,
                                     const QMap<QWidget*,QStringList>& alternativeTexts = QMap<QWidget*,QStringList>());
    static void centerWidgetPosition (QWidget* widget);
    static void moveWidgetIntoDesktop (QWidget* widget);
    static QPoint globalPosition (const QWidget* widget);
    static void moveToGlobalPosition (const QPoint& position, QWidget* widget);
};

template <typename widgetType>
class WidgetHelperPrivate
{
    WidgetHelperPrivate() {}
    static void setMaxWidgetWidth (widgetType* widget, const QStringList& texts, int& maxWidth);

    friend class WidgetHelper;
};

template <typename widgetType>
void WidgetHelperPrivate<widgetType>::setMaxWidgetWidth (widgetType* widget, const QStringList& texts, int& maxWidth)
{
    QString oldText = widget->text();

    for (int i = 0; i < texts.size(); i++)
    {
        widget->setText(texts.at(i));
        int width = widget->sizeHint().width();
        if (maxWidth < width)
            maxWidth = width;
    }

    widget->setText(oldText);
}

#endif // WIDGETHELPER_H
